home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 12: Textmags & Docs / nf_archive_12.iso / MAGS / SOURCES / ATARI_SRC.ZIP / atari source / HDX_BACK / HDX503 / ACSI.PRN < prev    next >
Encoding:
Text File  |  2001-02-09  |  57.9 KB  |  913 lines

  1.  
  2.                                         acsi.s               Page 1       12:13:14 am 18-Feb-1993     Madmac 1.07  (Atari ST)
  3.  
  4.  
  5.     1                                   ;+
  6.     2                                   ; Edit History
  7.     3                                   ;
  8.     4                                   ; May-22-89    ml.    Started this with AHDI 3.00.
  9.     5                                   ; Aug-21-89    ml.    Added format code.  It's seperated because it waits
  10.     6                                   ;            forever for command completion.
  11.     7                                   ; Sep-08-89    ml.    Added a 1 microsec delay (rstdelay()) after each 
  12.     8                                   ;            access to the DMA chip which may reset the chip.
  13.     9                                   ; Sep-13-89    ml.    If need to execute a command more than once to
  14.    10                                   ;            get all bytes into RAM, use the original allocation
  15.    11                                   ;            length for subsequent calls.
  16.    12                                   ; Oct-06-89    ml.    Added start/stop unit code.  It's seperated because
  17.    13                                   ;            it needs longer timeouts.
  18.    14                                   ; Nov-08-89    ml.    Added a delay in _rcvacsi() when looping to do more
  19.    15                                   ;            than one _sblkacsi().
  20.    16                                   ; Nov-27-89    ml.    Added .even after declaring control.
  21.    17                                   ; Dec-05-89    ml.    Flushing of D cache before reading status byte.
  22.    18                                   ; Apr-09-90    ml.    Added a "read" from WDL to actually "set" the bit
  23.    19                                   ;            for the new MMU chip.  It's a bug in the chip.  
  24.    20                                   ;            Temporary only.
  25.    21                                   ; Apr-20-90    ml.    Made the "read" added on Apr-09-90 conditional
  26.    22                                   ;            assembly.  RDWDL flag defined in defs.h.
  27.    23                                   ; Sep-24-91    ml.    Added the _slwacsi flag to indicate whether we
  28.    24                                   ;            are talking to a slow ACSI device.  If so, extra
  29.    25                                   ;            delay is necessary to wait for the device to
  30.    26                                   ;            response.
  31.    27                                   ; Oct-07-91    ml.    Instead of using "lsr" to check if transfer is
  32.    28                                   ;            a multiple of 16 in _rcvacsi(), use "andi".
  33.    29                                   ; Feb-13-92    ml.    Modified setacnt() so that if transfer length in
  34.    30                                   ;            bytes is greater than 512 but not a multiple of 512, 
  35.    31                                   ;            add 1 to the count in order to get all the data.
  36.    32                                   ;-
  37.    33                                   
  38.    34                                   
  39.    35                                   .include    "defs.h"
  40.     1                                   ;+
  41.     2                                   ; Conditional assembly
  42.     3                                   ;-
  43.     4           =00000001               DRIVER    equ    1            ; 0: not compiling for AHDI.PRG
  44.     5           =00000000               DEBUG    equ    0            ; 0: don't include debugging code
  45.     6           =00000000               RDWDL    equ    0            ; 0: don't need extra read from WDL
  46.     7                                   
  47.     8           =00000006               SCSIID    equ    6            ; our (host) SCSI ID
  48.     9                                   
  49.    10                                   
  50.    11                                   ;+
  51.    12                                   ; Restraints 
  52.    13                                   ;-
  53.    14           =0000000E               MAXLOG        equ    14        ; max # of log units w/o drv A & B
  54.    15           =00000008               MAXACSI        equ    8        ; maximum number of ACSI devices
  55.    16           =00000008               MAXSCSI        equ    8        ; maximum number of SCSI devices
  56.    17           =00000001               MAXIDE        equ    1        ; maximum number of IDE devices
  57.    18           =00000007               ACSIUNT        equ    7        ; highest ACSI unit number
  58.    19           =0000000F               SCSIUNT        equ    15        ; highest SCSI unit number
  59.    20           =00000010               IDEUNT        equ    16        ; highest IDE unit number
  60.    21           =000000FE               MAXACSECTS    equ    254        ; max # of sectors/ACSI gulp
  61.  
  62.  
  63.                                         defs.h               Page 2       12:13:14 am 18-Feb-1993     Madmac 1.07  (Atari ST)
  64.  
  65.  
  66.    22           =00003FFF               MAXSPSECTS    equ    16383        ; max # of sectors/Sparrow SCSI gulp
  67.    23                                                       ; Set from 16384 LT
  68.    24           =0000FFFE               MAXSCSECTS    equ    65534        ; max # of sectors/SCSI gulp
  69.    25           =00000100               MAXIDESECTS    equ    256        ; max # of sectors/IDE gulp
  70.    26                                   
  71.    27                                   
  72.    28                                   ;+
  73.    29                                   ; Machine type as defined in the _MCH cookie
  74.    30                                   ;-
  75.    31           =5F4D4348               _MCH    equ $5f4d4348        ; _MCH
  76.    32           =00000000               ST        equ    0
  77.    33           =00010000               STE        equ    $00010000
  78.    34           =00010008               STBOOK        equ    $00010008
  79.    35           =00010010               MSTE        equ    $00010010
  80.    36           =00020000               TT        equ    $00020000
  81.    37           =00030000               SPARROW        equ    $00030000    ; Changed to reflect ROMs LT
  82.    38                                   
  83.    39                                   ;+
  84.    40                                   ; Offsets to ...
  85.    41                                   ;-
  86.    42           =000001BE               DOSPM        equ    $1be        ; MSDOS boot sect's partition map
  87.    43           =000001FE               DOSSIG        equ    $1fe        ; MSDOS boot sect's signature
  88.    44           =000001C2               HDSIZ        equ    $1c2        ; offset to GEMDOS root sect's 
  89.    45                                   
  90.    46                                   
  91.    47                                   ;+
  92.    48                                   ; Constants and Variables
  93.    49                                   ;-
  94.    50           =000055AA               SIG        equ    $55aa        ; signature for valid MSDOS boot sects
  95.    51           =00000003               NRETRIES    equ    3        ; #retries-1
  96.    52           =00000003               MAXNPART    equ    3        ; #partition entries in root sect - 1
  97.    53           =00000012               BPBLEN        equ    18        ; length of bpb entry in bytes
  98.    54           =00000006               FATLEN        equ    6        ; max fat size = 2**6 = 64 sectors
  99.    55           =00000003               SERLEN        equ    3        ; length of a serial # in bytes
  100.    56           =19870422               CHKDATE        equ    $19870422    ; ROM date for bootstop checking
  101.    57                                   
  102.    58                                   
  103.    59                                   ;+
  104.    60                                   ; Number of bytes per Buffer Control Block (excluding the data block itself)
  105.    61                                   ;
  106.    62                                   ; struct_bcb {
  107.    63                                   ;     struct_bcb    *b_link;    /* 4 bytes */
  108.    64                                   ;    int        b_neg1;        /* 2 bytes */
  109.    65                                   ;    int        b_private[5];    /* 10 bytes */
  110.    66                                   ;    char        *b_bufr;    /* 4 bytes */
  111.    67                                   ; };
  112.    68                                   ;
  113.    69                                   ; For GEMDOS buffer lists.
  114.    70                                   ;-
  115.    71           =00000014               BCBLEN        equ    20
  116.    72                                   
  117.    73                                   
  118.    74                                   ;+
  119.    75                                   ; Number of bytes per IDE drive parameters structure
  120.    76                                   ;
  121.    77                                   ; struct_idedp {
  122.  
  123.  
  124.                                         defs.h               Page 3       12:13:14 am 18-Feb-1993     Madmac 1.07  (Atari ST)
  125.  
  126.  
  127.    78                                   ;    int    nhead;        /* # of data heads */
  128.    79                                   ;    int    nspt;        /* # of physical sectors per track */
  129.    80                                   ; };
  130.    81                                   ;-
  131.    82           =00000004               IDEDPLEN    equ    4
  132.    83                                   
  133.    84                                   
  134.    85                                   ;+
  135.    86                                   ; for extension of OS pool
  136.    87                                   ;-
  137.    88           =00000042               chunksiz    equ     66        ; #bytes/chunk
  138.    89           =00000004               chunkno        equ     4        ; chunk# (4 16-byte chunks)
  139.    90                                   
  140.    91                                   
  141.    92                                   ;+
  142.    93                                   ; for checking existence of fast RAM
  143.    94                                   ;    If long word at _ramvalid == RAMMAGIC
  144.    95                                   ; then  _ramtop is valid.  If _ramtop contains 0, no fast RAM is available,
  145.    96                                   ; else _ramtop contains the address of top (end) of memory
  146.    97                                   ;
  147.    98                                   ; Fast RAM always starts at $01000000.
  148.    99                                   ; _ramtop may hold $01000000 meaning there is no fast RAM!
  149.   100                                   ;
  150.   101                                   ; RAMRSV must be smaller than MAXACSECTS
  151.   102                                   ;-
  152.   103           =1357BD13               RAMMAGIC    equ    $1357bd13    ; magic cookie for fast RAM
  153.   104           =01000000               RAMBOT        equ    $01000000    ; where fast RAM starts
  154.   105           =00000080               RAMRSV        equ    $80        ; # sectors of reserved RAM (64k)
  155.   106                                   
  156.   107                                   
  157.   108                                   ;+
  158.   109                                   ; Vector address
  159.   110                                   ;-
  160.   111           =00000008               BERR        equ    $8        ; Bus ERRor vector
  161.   112           =00000010               IINS        equ    $10        ; Illegal INStruction vector
  162.   113                                   
  163.   114                                   
  164.    36                                   .include    "sysvar.h"
  165.     1                                   ;+
  166.     2                                   ; Equates for systems variables
  167.     3                                   ;-
  168.     4           =00000404               etv_critic    equ    $404        ; critical error handoff vector
  169.     5           =0000042E               phystop        equ    $42e        ; physical top of memory
  170.     6           =0000043E               flock        equ    $43e        ; FIFO lock variable
  171.     7           =00000446               _bootdev    equ    $446        ; default boot device
  172.     8           =0000046A               hdv_init    equ    $46a        ; hdv_init()    ** UNUSED **
  173.     9           =00000472               hdv_bpb        equ    $472        ; hdv_bpb(dev)
  174.    10           =00000476               hdv_rw        equ    $476        ; hdv_rw(rw, buf, count, recno, dev)
  175.    11           =0000047A               hdv_boot    equ    $47a        ; hdv_boot()    ** UNUSED **
  176.    12           =0000047E               hdv_mediach    equ    $47e        ; hdv_mediach(dev)
  177.    13           =000004B2               _bufl        equ    $4b2        ; 2 buffer-list headers
  178.    14           =000004BA               _hz_200        equ    $4ba        ; system 200hz timer
  179.    15           =000004C2               _drvbits    equ    $4c2        ; block device bitVector
  180.    16           =000004C6               _dskbufp    equ    $4c6        ; pointer to common disk buffer
  181.    17           =000004F2               _sysbase    equ    $4f2        ; -> base of OS
  182.    18           =00000516               pun_ptr        equ    $516        ; number of physical units
  183.  
  184.  
  185.                                         acsi.s               Page 4       12:13:14 am 18-Feb-1993     Madmac 1.07  (Atari ST)
  186.  
  187.  
  188.    19           =000005A0               _p_cookie    equ    $5a0        ; pointer to cookie jar
  189.    37                                   .include    "mfp.h"
  190.     1                                   ;+
  191.     2                                   ; Oct-04-90    ml.    Created this to share by files that need to
  192.     3                                   ;             know addresses in MFP.
  193.     4                                   ;-
  194.     5                                   
  195.     6                                   
  196.     7                                   ; Definitions
  197.     8           =00000001               REGBASE        equ    1    ; most are on odd part of data bus
  198.     9           =00000002               REGSTEP        equ    2    ; for those that are on word boundaries
  199.    10           =00000004               REGLSTEP    equ    4    ; for those that are on long word boundaries
  200.    11                                   
  201.    12                                   
  202.    13                                   ; 68901 MFP definitions
  203.    14                                   
  204.    15           =FFFFFA01               MFP    equ    $FFFFFA01
  205.    16                                   
  206.    17           =FFFFFA01               GPIP    equ    MFP+$00
  207.    18           =FFFFFA03               AER    equ    MFP+$02
  208.    19           =FFFFFA05               DDR    equ    MFP+$04
  209.    20           =FFFFFA07               IERA    equ    MFP+$06
  210.    21           =FFFFFA09               ERB    equ    MFP+$08
  211.    22           =FFFFFA0B               IPRA    equ    MFP+$0A
  212.    23           =FFFFFA0D               IPRB    equ    MFP+$0C
  213.    24           =FFFFFA0F               ISRA    equ    MFP+$0E
  214.    25           =FFFFFA11               ISRB    equ    MFP+$10
  215.    26           =FFFFFA13               IMRA    equ    MFP+$12
  216.    27           =FFFFFA15               IMRB    equ    MFP+$14
  217.    28           =FFFFFA17               VR    equ    MFP+$16
  218.    29           =FFFFFA19               TACR    equ    MFP+$18
  219.    30           =FFFFFA1B               TBCR    equ    MFP+$1A
  220.    31           =FFFFFA1D               TCDCR    equ    MFP+$1C
  221.    32           =FFFFFA1F               TADR    equ    MFP+$1E
  222.    33           =FFFFFA21               TBDR    equ    MFP+$20
  223.    34           =FFFFFA23               TCDR    equ    MFP+$22
  224.    35           =FFFFFA25               TDDR    equ    MFP+$24
  225.    36           =FFFFFA27               SCR    equ    MFP+$26
  226.    37           =FFFFFA29               UCR    equ    MFP+$28
  227.    38           =FFFFFA2B               RSR    equ    MFP+$2A
  228.    39           =FFFFFA2D               TSR    equ    MFP+$2C
  229.    40           =FFFFFA2F               UDR    equ    MFP+$2E
  230.    41                                   
  231.    42           =FFFFFA81               MFP2    equ    $FFFFFA81
  232.    43           =FFFFFA81               GPIP2    equ    MFP2+$00
  233.    44           =FFFFFA83               AER2    equ    MFP2+$02
  234.    45           =FFFFFA85               DDR2    equ    MFP2+$04
  235.    46           =FFFFFA87               IERA2    equ    MFP2+$06
  236.    47           =FFFFFA89               IERB2    equ    MFP2+$08
  237.    48           =FFFFFA8B               IPRA2    equ    MFP2+$0A
  238.    49           =FFFFFA8D               IPRB2    equ    MFP2+$0C
  239.    50           =FFFFFA8F               ISRA2    equ    MFP2+$0E
  240.    51           =FFFFFA91               ISRB2    equ    MFP2+$10
  241.    52           =FFFFFA93               IMRA2    equ    MFP2+$12
  242.    53           =FFFFFA95               IMRB2    equ    MFP2+$14
  243.    54           =FFFFFA97               VR2    equ    MFP2+$16
  244.  
  245.  
  246.                                         mfp.h                Page 5       12:13:14 am 18-Feb-1993     Madmac 1.07  (Atari ST)
  247.  
  248.  
  249.    55           =FFFFFA99               TACR2    equ    MFP2+$18
  250.    56           =FFFFFA9B               TBCR2    equ    MFP2+$1A
  251.    57           =FFFFFA9D               TCDCR2    equ    MFP2+$1C
  252.    58           =FFFFFA9F               TADR2    equ    MFP2+$1E
  253.    59           =FFFFFAA1               TBDR2    equ    MFP2+$20
  254.    60           =FFFFFAA3               TCDR2    equ    MFP2+$22
  255.    61           =FFFFFAA5               TDDR2    equ    MFP2+$24
  256.    62           =FFFFFAA7               SCR2    equ    MFP2+$26
  257.    63           =FFFFFAA9               UCR2    equ    MFP2+$28
  258.    64           =FFFFFAAB               RSR2    equ    MFP2+$2A
  259.    65           =FFFFFAAD               TSR2    equ    MFP2+$2C
  260.    66           =FFFFFAAF               UDR2    equ    MFP2+$2E
  261.    67                                       
  262.    68                                   
  263.    69                                   
  264.    38                                   .include    "acsi.h"
  265.     1                                   ;  Hardware definitions for ACSI DMA channel
  266.     2           =FFFF8604               WDC        equ    $ffff8604
  267.     3           =FFFF8606               WDL        equ    $ffff8606
  268.     4           =FFFF860F               WDSR        equ    $ffff860f    ; Select Register
  269.     5           =FFFF8604               WDCWDL        equ    WDC        ; used for long writes
  270.     6           =00000002               XWDL        equ    WDL-WDC        ; offset from wdc to wdl
  271.     7                                   
  272.     8           =FFFF8609               DMAHI        equ    $ffff8609
  273.     9           =FFFF860B               DMAMID        equ    DMAHI+2
  274.    10           =FFFF860D               DMALOW        equ    DMAMID+2
  275.    11                                   
  276.    12           =00000003               STA        equ    3        ; Internal DMA status bit
  277.    13                                                       ;  in the select register
  278.    14                                   
  279.    39                                   .include    "68030.s"
  280.     1                                       .macro    movecd0vbr
  281.     2                                 .     dc.w    $4E7B
  282.     3                                 .     dc.w    $0801
  283.     4                                 .     .endm
  284.     5                                   
  285.     6                                       .macro    movecvbrd0
  286.     7                                 .     dc.w    $4E7A
  287.     8                                 .     dc.w    $0801
  288.     9                                 .     .endm
  289.    10                                   
  290.    11                                       .macro    movecacrd0
  291.    12                                 .     dc.w    $4E7A
  292.    13                                 .     dc.w    $0002
  293.    14                                 .     .endm
  294.    15                                   
  295.    16                                       .macro    moved0cacr
  296.    17                                 .     dc.w    $4E7B
  297.    18                                 .     dc.w    $0002
  298.    19                                 .     .endm
  299.    20                                   
  300.    21                                   ; unsigned long multiply immediate producing a word in specified register
  301.    22                                       .macro    mululwi    val,dstreg
  302.    23                                 .     dc.w    $4C3C
  303.    24                                 .     dc.w    \dstreg << 12
  304.    25                                 .     dc.l    \val
  305.  
  306.  
  307.                                         68030.s              Page 6       12:13:14 am 18-Feb-1993     Madmac 1.07  (Atari ST)
  308.  
  309.  
  310.    26                                 .     .endm
  311.    27                                   
  312.    28                                   ; unsigned long divide 32/32 -> 32r:32q
  313.    29                                       .macro    divulr    eareg,regr,regq
  314.    30                                 .     dc.w    $4C40+\eareg    ; divu.l d?,
  315.    31                                 .     dc.w    (\regq << 12)+\regr
  316.    32                                 .     .endm
  317.    40                                   
  318.    41                                   
  319.    42                                   ;+
  320.    43                                   ;  Tunable (delay) values for ACSI
  321.    44                                   ;-
  322.    45           =00000258               ACLTMOUT    equ    600        ; long-timeout (3 S)
  323.    46           =00000014               ACSTMOUT    equ    20        ; short-timeout (100 mS)
  324.    47           =00001388               SLWACLTO    equ    5000        ; long-timeout (25 S) for slow ACSI
  325.    48           =0000002A               SLWACSTO    equ    42        ; short-timeout (205 mS) for slow ACSI
  326.    49                                   
  327.    50                                   
  328.    51                                   ;+
  329.    52                                   ; Declarations
  330.    53                                   ;-
  331.    54  00000000  00000000               lastacstm:    dc.l    0        ; controller last accessed time
  332.    55  00000004  00                     control:    dc.b    0        ; flag for sending control byte
  333.    56                                           .globl    _slwacsi
  334.    57  00000005  00                     _slwacsi:    dc.b    0        ; assume not doing slow ACSI
  335.    58                                   .even
  336.    59                                   
  337.    60                                   .extern        _cmdblk
  338.    61                                   
  339.    62                                   
  340.    63                                   ;+
  341.    64                                   ; LONG _qdone() - Wait for command byte handshake
  342.    65                                   ; LONG _fdone() - Wait for operation complete
  343.    66                                   ; Passed:    nothing
  344.    67                                   ;
  345.    68                                   ; Returns:    EQ: no timeout
  346.    69                                   ;        MI: timeout condition
  347.    70                                   ;
  348.    71                                   ; Uses:        D0
  349.    72                                   ;
  350.    73                                   ;-
  351.    74                                   
  352.    75                                   .if    !DRIVER
  353.    76                                 - _slwfdone:                ; fdone for slow response
  354.    77                                 -     move.l    #SLWACLTO,d0
  355.    78                                 -     bra.s    qd0
  356.    79                                 - .endif
  357.    80                                   
  358.    81  00000006  203C00000258           _fdone:    move.l    #ACLTMOUT,d0
  359.    82  0000000C  60xx                       bra.s    qd0
  360.    83                                   
  361.    84                                   .if    !DRIVER
  362.    85                                 - _slwqdone:                ; qdone for slow response
  363.    86                                 -     moveq    #SLWACSTO,d0    
  364.    87                                 -     bra.s    qd0
  365.    88                                 - .endif
  366.  
  367.  
  368.                                         acsi.s               Page 7       12:13:14 am 18-Feb-1993     Madmac 1.07  (Atari ST)
  369.  
  370.  
  371.    89                                   
  372.    90  0000000E  7014                   _qdone:    moveq    #ACSTMOUT,d0
  373.    91                                   
  374.    92  00000010  4A3900000005           qd0:    tst.b    _slwacsi        ; talking to slow ACSI device?
  375.    93  00000016  67xx                       beq.s    qd1            ; if not, go wait for interrupt
  376.    94                                                       ; else
  377.    95  00000018  2F00                       move.l    d0,-(sp)        ; save timeout value
  378.    96  0000001A  7002                       moveq    #2,d0            ; busy-wait delay for slow ACSI
  379.    97  0000001C  D0B804BA               sdelay:    add.l    _hz_200,d0        ; minimum 20 microsec.
  380.    98  00000020  B0B804BA                   cmp.l    _hz_200,d0
  381.    99  00000024  6CF6                       bge.s    sdelay
  382.   100  00000026  201F                       move.l    (sp)+,d0        ; restore timeout value
  383.   101                                   
  384.   102  00000028  D0B804BA               qd1:    add.l    _hz_200,d0
  385.   103  0000002C  B0B804BA               qd2:    cmp.l    _hz_200,d0        ; timeout?
  386.   104  00000030  65xx                       bcs.s    qdq            ; (i give up, return NE)
  387.   105  00000032  08380005FA01               btst    #5,GPIP        ; interrupt?
  388.   106  00000038  66F2                       bne.s    qd2            ; (not yet)
  389.   107                                   
  390.   108  0000003A  7000                       moveq    #0,d0            ; return EQ (no timeout)
  391.   109  0000003C  4E75                       rts
  392.   110                                   
  393.   111  0000003E  70FF                   qdq:    moveq    #-1,d0
  394.   112  00000040  4E75                       rts
  395.   113                                   
  396.   114                                   
  397.   115                                   ;+
  398.   116                                   ; Wait for end of SASI command
  399.   117                                   ;
  400.   118                                   ; Passed:    d1 value to be written to wdl
  401.   119                                   ;
  402.   120                                   ; Returns:    EQ: success (error code in D0.W)
  403.   121                                   ;        MI: timeout (-1 in D0.W)
  404.   122                                   ;        NE: failure (SASI error code in D0.W)
  405.   123                                   ;
  406.   124                                   ; Uses:        d0
  407.   125                                   ;
  408.   126                                   ; Comments: (12/05/89)
  409.   127                                   ;    The flushing of D cache is necessary per Jim Tittsler.  For
  410.   128                                   ; detail, refer to mail sent by jwt on 12/04/89 about ACSI DMA.
  411.   129                                   ;-
  412.   130                                   .if    !DRIVER
  413.   131                                 -     .globl    _cachexst
  414.   132                                 - _cachexst:    dc.b    0
  415.   133                                 - 
  416.   134                                 - _slwendcmd:
  417.   135                                 -     bsr    _slwfdone        ; wait for operation complete
  418.   136                                 -     bra.s    end0
  419.   137                                 - .else
  420.   138                                       .extern    _cachexst
  421.   139                                   .endif
  422.   140                                   
  423.   141                                   _endcmd:
  424.   142  00000042  61C2                       bsr    _fdone            ; wait for operation complete
  425.   143  00000044  6Bxx                   end0:    bmi.s    endce            ; (timed-out, so complain)
  426.   144                                   
  427.  
  428.  
  429.                                         acsi.s               Page 8       12:13:14 am 18-Feb-1993     Madmac 1.07  (Atari ST)
  430.  
  431.  
  432.   145  00000046  4A39xxxxxxxx           cmdcmp:    tst.b    _cachexst        ; '030 cache exists
  433.   146  0000004C  67xx                       beq.s    end1            ; if not, fine
  434.   147                                                       ; else, dump D cache
  435.   148  0000004E  40E7                       move.w    sr,-(sp)        ; go to IPL 7
  436.   149  00000050  007C0700                   ori.w    #$700,sr        ; no interrupts right now kudasai
  437.                                             movecacrd0            ; d0 = (cache control register)
  438.        00000054  4E7A                 @     dc.w    $4E7A
  439.   150  00000056  0002                 @     dc.w    $0002
  440.   151  00000058  00400800                   ori.w    #$800,d0        ; dump the D cache
  441.                                             moved0cacr            ; update cache control register
  442.        0000005C  4E7B                 @     dc.w    $4E7B
  443.   152  0000005E  0002                 @     dc.w    $0002
  444.   153  00000060  46DF                       move.w    (sp)+,sr        ; restore interrupt state
  445.   154                                   
  446.   155  00000062  31C18606               end1:    move.w    d1,WDL
  447.   156  00000066  30388604                   move.w    WDC,d0            ; get the result
  448.   157  0000006A  C07C00FF                   and.w    #$00ff,d0        ; (clean it up), if non-zero should
  449.   158                                                       ; do a ReadSense command to learn more
  450.   159  0000006E  23F804BA00000000       endce:    move.l    _hz_200,lastacstm    ; update controller last accessed time
  451.   160  00000076  54B900000000               addq.l    #2,lastacstm        ; lastacstm = _hz_200 + 2;
  452.   161  0000007C  4E75                       rts                
  453.   162                                   
  454.   163                                   
  455.   164                                   ;+
  456.   165                                   ;  Unlock DMA chip and return completion status;
  457.   166                                   ;-
  458.   167                                       .globl    _hdone
  459.   168  0000007E  31FC01808606           _hdone:    move.w    #$180,WDL    ; reset the chip for floppy
  460.   169  00000084  6100xxxx                   bsr    rstdelay
  461.   170  00000088  31FC00808606               move.w    #$80,WDL    ; Landon's code seems to presume we put 
  462.   171                                                   ;  $80 there
  463.   172  0000008E  4278043E                   clr    flock        ; NOW, signal that we are done
  464.   173  00000092  4E75                       rts
  465.   174                                   
  466.   175                                   
  467.   176                                   ;+
  468.   177                                   ; delay()
  469.   178                                   ;    5 - 10ms kludge delay for message byte sent back by controller.
  470.   179                                   ;-
  471.   180  00000094  2F00                   _delay:    move.l    d0,-(sp)        ; preserve d0
  472.   181  00000096  203900000000               move.l    lastacstm,d0        ; d0 = controller last accessed time
  473.   182  0000009C  B0B804BA               wait:    cmp.l    _hz_200,d0        ; while (_hz_200 <= lastacstm)
  474.   183  000000A0  64FA                       bcc.s    wait            ;    wait()
  475.   184  000000A2  201F                       move.l    (sp)+,d0        ; restore d0
  476.   185  000000A4  4E75                       rts
  477.   186                                   
  478.   187                                   
  479.   188                                   ;+
  480.   189                                   ; smplacsi() - send a simple ACSI command (ie. no DMA involved)
  481.   190                                   ;
  482.   191                                   ;    d0.w = physical unit number
  483.   192                                   ;    d1.l = transfer length (in bytes)
  484.   193                                   ;    d2.w = command length (NCMD or LCMD)
  485.   194                                   ;    a0.l = buffer address
  486.   195                                   ;-
  487.   196                                       .globl    _smplacsi
  488.  
  489.  
  490.                                         acsi.s               Page 9       12:13:14 am 18-Feb-1993     Madmac 1.07  (Atari ST)
  491.  
  492.  
  493.   197                                   _smplacsi:
  494.   198  000000A6  50F8043E                   st    flock            ; lock FIFO
  495.   199  000000AA  61E8                       bsr    _delay            ; delay if necessary
  496.   200  000000AC  227CFFFF8604               movea.l    #WDC,a1            ; a1 = pointer to DMA chip
  497.   201  000000B2  02400007                   andi.w    #7,d0            ; mask off the flags to get unit num
  498.   202  000000B6  7200                       moveq    #0,d1            ; no DMA
  499.   203  000000B8  6100xxxx                   bsr    sblkacsi        ; send command block
  500.   204  000000BC  60C0                       bra    _hdone            ; cleanup after IRQ
  501.   205                                   
  502.   206                                   
  503.   207                                   ;+
  504.   208                                   ; rcvacsi() - send a ACSI command which receives data back.
  505.   209                                   ;
  506.   210                                   ; Passed:
  507.   211                                   ;    d0.w = physical unit number
  508.   212                                   ;    d1.l = transfer length (in bytes)
  509.   213                                   ;    d2.w = command length (NCMD or LCMD)
  510.   214                                   ;    a0.l = buffer address
  511.   215                                   ;
  512.   216                                   ; Comments:
  513.   217                                   ;    This routine assumes that if you are transferring more than 512
  514.   218                                   ; bytes, the transfer length must be a multiple of 16 bytes.  It also 
  515.   219                                   ; assumes the allocation length byte is always at byte 4 in the command
  516.   220                                   ; block. (Therefore, it won't work with Receive Diagnostic ($1c) if data
  517.   221                                   ; length is not a multiple of 16 bytes.  But Receive Diagnostic has never
  518.   222                                   ; been used.)
  519.   223                                   ;    The transfer length in register D1 MUST be greater than 0.
  520.   224                                   ;-
  521.   225                                       .globl    _rcvacsi
  522.   226                                   _rcvacsi:
  523.   227  000000BE  50F8043E                   st    flock            ; lock FIFO
  524.   228  000000C2  3F03                       move.w    d3,-(sp)        ; preserve d3
  525.   229  000000C4  61CE                       bsr    _delay            ; delay if necessary
  526.   230  000000C6  227CFFFF8604               movea.l    #WDC,a1            ; a1 = pointer to DMA chip
  527.   231                                   
  528.   232  000000CC  6100xxxx                   bsr    setadma            ; set DMA pointer
  529.   233  000000D0  337C01900002               move.w    #$190,XWDL(a1)    ;WDL    ; toggle DMA chip for "receive"
  530.   234  000000D6  6100xxxx                   bsr    rstdelay        ; delay
  531.   235  000000DA  337C00900002               move.w    #$090,XWDL(a1)    ;WDL
  532.   236  000000E0  6100xxxx                   bsr    rstdelay        ; delay
  533.   237                                   
  534.   238                                   .if    RDWDL
  535.   239                                 -     tst.w    XWDL(a1)        ; to point MMU to correct direction
  536.   240                                 - .endif    ;RDWDL
  537.   241                                   
  538.   242  000000E4  6100xxxx                   bsr    setacnt            ; set DMA count
  539.   243                                   
  540.   244  000000E8  02400007                   andi.w    #7,d0            ; mask off the flags to get unit num
  541.   245                                                       ; find # times need to send it
  542.   246  000000EC  0C8100000200               cmpi.l    #512,d1            ; transferring < 512 bytes?
  543.   247  000000F2  65xx                       bcs.s    .0            ; if so, go find # times to send
  544.   248  000000F4  7200                       moveq    #0,d1            ; else assume it's 16*n, send once
  545.   249  000000F6  60xx                       bra.s    .4
  546.   250                                   
  547.   251  000000F8  3601                   .0:    move.w    d1,d3            ; d3 = transfer length
  548.   252  000000FA  0C410010                   cmpi.w    #16,d1            ; transferring < 16 bytes?
  549.  
  550.  
  551.                                         acsi.s               Page 10      12:13:14 am 18-Feb-1993     Madmac 1.07  (Atari ST)
  552.  
  553.  
  554.   253  000000FE  65xx                       bcs.s    .1            ; if so, find # times to make 16 bytes
  555.   254                                   
  556.   255  00000100  0241000F                   andi.w    #$0f,d1            ; else, is it multiple of 16 bytes?
  557.   256  00000104  67xx                       beq.s    .4            ; if so, just do once (d1.w = 0)
  558.   257  00000106  7201                       moveq    #1,d1            ; else, need to do twice
  559.   258  00000108  60xx                       bra.s    .4
  560.   259                                   
  561.   260  0000010A  7210                   .1:    moveq    #16,d1            ; find # times to make 16 bytes
  562.   261  0000010C  82C3                       divu    d3,d1            ; d1.w = 16 / transfer length
  563.   262  0000010E  5341                       subq.w    #1,d1            ; dbra likes one less
  564.   263                                   
  565.   264  00000110  4841                   .2:    swap    d1            ; d1.w = remainder
  566.   265  00000112  4A41                       tst.w    d1            ; any remainder?
  567.   266  00000114  66xx                       bne.s    .3            ; if yes, go add one to the quotient
  568.   267  00000116  4841                       swap    d1            ; if no, # times to send = quotient
  569.   268  00000118  60xx                       bra.s    .4
  570.   269                                   
  571.   270  0000011A  4841                   .3:    swap    d1            ; d1.w    = # times to send command
  572.   271  0000011C  5241                       addq.w    #1,d1            ;    = quotient + 1
  573.   272                                   
  574.   273  0000011E  41F9xxxxxxxx           .4:    lea    _cmdblk,a0        ; a0 = address of command block
  575.   274  00000124  48E7E080               .5:    movem.l    d0-d2/a0,-(sp)        ; save d0 through d2 and a0
  576.   275  00000128  7200                       moveq    #0,d1            ; direction of DMA is IN
  577.   276  0000012A  6100FF68                   bsr    _delay            ; delay if necessary
  578.   277  0000012E  6100xxxx                   bsr    sblkacsi        ; send the command block
  579.   278  00000132  4A40                       tst.w    d0            ; successful?
  580.   279  00000134  66xx                       bne.s    .7            ; if not, quit
  581.   280  00000136  4CDF0107                   movem.l    (sp)+,d0-d2/a0        ; else restore d0 through d2 and a0
  582.   281  0000013A  51C9xxxx                   dbra    d1,.6            ; done yet?
  583.   282  0000013E  7000                       moveq    #0,d0            ; command block sent successfully
  584.   283  00000140  60xx                       bra.s    raend            ; phone home...
  585.   284                                   
  586.   285  00000142  70FF                   .6:    moveq    #-1,d0            ; unit number already in command block
  587.   286  00000144  11430004                   move.b    d3,4(a0)        ; modify transfer length
  588.   287  00000148  60DA                       bra.s    .5            ; send it enough times
  589.   288                                   
  590.   289  0000014A  DEFC0010               .7:    adda    #16,sp            ; cleanup stack
  591.   290  0000014E  361F                   raend:    move.w    (sp)+,d3        ; restore d3
  592.   291  00000150  6000FF2C                   bra    _hdone            ; cleanup after IRQ
  593.   292                                   
  594.   293                                   
  595.   294                                   ;+
  596.   295                                   ; wrtacsi() - send an ACSI command which will write data to the target
  597.   296                                   ;
  598.   297                                   ; Passed:
  599.   298                                   ;    d0.w = physical unit number
  600.   299                                   ;    d1.l = transfer length (in bytes)
  601.   300                                   ;    d2.w = command length (NCMD or LCMD)
  602.   301                                   ;    a0.l = buffer address
  603.   302                                   ;-
  604.   303                                       .globl    _wrtacsi
  605.   304                                   _wrtacsi:
  606.   305  00000154  50F8043E                   st    flock            ; lock FIFO
  607.   306  00000158  6100FF3A                   bsr    _delay
  608.   307  0000015C  227CFFFF8604               movea.l    #WDC,a1            ; a1 = pointer to DMA chip
  609.   308                                   
  610.  
  611.  
  612.                                         acsi.s               Page 11      12:13:14 am 18-Feb-1993     Madmac 1.07  (Atari ST)
  613.  
  614.  
  615.   309  00000162  6100xxxx                   bsr    setadma            ; set DMA pointer
  616.   310  00000166  337C00900002               move.w    #$90,XWDL(a1)    ;WDL    ; toggle DMA chip for "send"
  617.   311  0000016C  6100xxxx                   bsr    rstdelay        ; delay 
  618.   312  00000170  337C01900002               move.w    #$190,XWDL(a1)    ;WDL
  619.   313  00000176  6100xxxx                   bsr    rstdelay        ; delay
  620.   314                                   
  621.   315                                   .if    RDWDL
  622.   316                                 -     tst.w    XWDL(a1)        ; to point MMU to correct direction
  623.   317                                 - .endif    ;RDWDL
  624.   318                                   
  625.   319  0000017A  6100xxxx                   bsr    setacnt            ; set DMA count
  626.   320                                       
  627.   321  0000017E  02400007                   andi.w    #7,d0            ; mask off the flags to get unit num
  628.   322  00000182  223C00000100               move.l    #$0100,d1        ; d1 = direction of DMA is OUT
  629.   323  00000188  6100xxxx                   bsr    sblkacsi        ; send the command block
  630.   324                                   
  631.   325  0000018C  6000FEF0               waend:    bra    _hdone            ; cleanup after IRQ
  632.   326                                   
  633.   327                                   
  634.   328                                   ;+
  635.   329                                   ; sblkacsi() - set DMA pointer and count and send command block
  636.   330                                   ;
  637.   331                                   ; Passed:
  638.   332                                   ;    d0.w = physical unit number
  639.   333                                   ;    d1.l = direction of DMA ($0000 for IN or $0100 for OUT)
  640.   334                                   ;    d2.w = command length (NCMD or LCMD)
  641.   335                                   ;    a1.l = pointer to DMA chip
  642.   336                                   ;
  643.   337                                   ; Returns:
  644.   338                                   ;    d0.l =  0 if successful
  645.   339                                   ;    d0.l = -1 if timeout
  646.   340                                   ;
  647.   341                                   ; Trashes:
  648.   342                                   ;    d0, d1, d2, a2
  649.   343                                   ;-
  650.   344                                   sblkacsi:
  651.   345  00000190  123C0088                   move.b    #$88,d1            ; next byte is the opcode
  652.   346  00000194  33410002                   move.w    d1,XWDL(a1)    ;WDL
  653.   347                                   
  654.   348  00000198  123C008A                   move.b    #$8a,d1            ; following bytes are operands
  655.   349  0000019C  45F9xxxxxxxx               lea    _cmdblk,a2        ; a2 = address of command block
  656.   350                                   
  657.   351  000001A2  4A40                       tst.w    d0            ; is unit # already in command block
  658.   352  000001A4  6Bxx                       bmi.s    .0            ; if yes, just send command block
  659.   353                                                       ; else integrate unit # into cmd blk
  660.   354  000001A6  EB08                       lsl.b    #5,d0            ; shift unit number into place
  661.   355  000001A8  8112                       or.b    d0,(a2)            ; first command byte = unit # | opcode
  662.   356                                                       ; control byte is sent seperately
  663.   357  000001AA  5542                   .0:    subq.w    #2,d2            ; and dbra likes one less 
  664.   358  000001AC  4841                   .1:    swap    d1            ; d1.hw = operand
  665.   359  000001AE  121A                       move.b    (a2)+,d1        ; d1.lw = tells controller next byte
  666.   360  000001B0  4841                       swap    d1            ;      is an operand
  667.   361  000001B2  2281                       move.l    d1,(a1)        ;WDCWDL
  668.   362  000001B4  6100FE58                   bsr    _qdone
  669.   363  000001B8  6Bxx                       bmi.s    sbaend            ; if timeout, returns
  670.   364  000001BA  51CAFFF0                   dbra    d2,.1            ; else send rest of command block
  671.  
  672.  
  673.                                         acsi.s               Page 12      12:13:14 am 18-Feb-1993     Madmac 1.07  (Atari ST)
  674.  
  675.  
  676.   365                                   
  677.   366  000001BE  33410002                   move.w    d1,XWDL(a1)    ;WDL    ; else get ready to send control byte
  678.   367  000001C2  123C0000                   move.b    #0,d1            ; signal sending control byte
  679.   368  000001C6  4841                       swap    d1            ; d1.hw = operand
  680.   369  000001C8  1212                       move.b    (a2),d1            ; d1.lw = tells controller it's end
  681.   370  000001CA  4841                       swap    d1            ;      of command
  682.   371  000001CC  2281                       move.l    d1,(a1)            ; send it
  683.   372                                   
  684.   373  000001CE  123C008A                   move.b    #$8a,d1            ; d1 = wdl value
  685.   374  000001D2  6100FE6E                   bsr    _endcmd            ; wait for command completion
  686.   375  000001D6  4E75                   sbaend: rts                ; heading home
  687.   376                                   
  688.   377                                   
  689.   378                                   ;+
  690.   379                                   ; setadma() - set the ACSI DMA pointer
  691.   380                                   ;
  692.   381                                   ; Passed:
  693.   382                                   ;    a0.l = buffer address
  694.   383                                   ;-
  695.   384                                       .globl    setadma
  696.   385                                   setadma:
  697.   386  000001D8  2F08                       move.l    a0,-(sp)        ; move it on stack
  698.   387  000001DA  11EF0003860D               move.b    3(sp),DMALOW        ; set low-byte of address
  699.   388  000001E0  11EF0002860B               move.b    2(sp),DMAMID        ; set mid-byte of address
  700.   389  000001E6  11EF00018609               move.b    1(sp),DMAHI        ; set high-byte of address
  701.   390  000001EC  588F                       addq.l    #4,sp            ; clean up stack
  702.   391  000001EE  4E75                       rts
  703.   392                                   
  704.   393                                   
  705.   394                                   ;+
  706.   395                                   ; setacnt() - set the ACSI DMA counter
  707.   396                                   ;
  708.   397                                   ; Passed:
  709.   398                                   ;    d1.l = transfer length (in bytes)
  710.   399                                   ;    a1.l = pointer to DMA chip
  711.   400                                   ;-
  712.   401                                       .globl    setacnt
  713.   402                                   setacnt:
  714.   403  000001F0  0C8100000200               cmpi.l    #512,d1            ; transferring more than 512 bytes?
  715.   404  000001F6  62xx                       bhi.s    .0            ; if so, find transfer len in blocks
  716.   405  000001F8  32BC0001                   move.w    #1,(a1)        ;WDC    ; else set DMA count to 1 block
  717.   406  000001FC  60xx                       bra.s    sacend
  718.   407  000001FE  48E76000               .0:    movem.l    d1-d2,-(sp)        ; save d1 and d2
  719.   408  00000202  2401                       move.l    d1,d2            ; d2 = transfer length (in bytes)
  720.   409  00000204  E089                       lsr.l    #8,d1            ; find transfer length (in blocks)
  721.   410  00000206  E289                       lsr.l    #1,d1            ; d1 >>= 9 = transfer len (in blocks)
  722.   411  00000208  0282000001FF               andi.l    #$1ff,d2        ; multiples of 512?
  723.   412  0000020E  67xx                       beq.s    .1            ; if so, go set count
  724.   413  00000210  D27C0001                   add.w    #1,d1            ; else increment count by one    
  725.   414  00000214  3281                   .1:    move.w    d1,(a1)        ;WDC    ; set DMA count
  726.   415  00000216  4CDF0006                   movem.l    (sp)+,d1-d2        ; restore d1 and d2
  727.   416  0000021A  4E75                   sacend:    rts
  728.   417                                   
  729.   418                                   
  730.   419                                   
  731.   420                                   .if    !DRIVER                ; not to be included in driver
  732.  
  733.  
  734.                                         acsi.s               Page 13      12:13:14 am 18-Feb-1993     Madmac 1.07  (Atari ST)
  735.  
  736.  
  737.   421                                 - 
  738.   422                                 - ;+
  739.   423                                 - ; fmtacsi() - format an ACSI unit
  740.   424                                 - ;
  741.   425                                 - ;    d0.w = physical unit number
  742.   426                                 - ;    d2.w = command length (NCMD or LCMD)
  743.   427                                 - ;-
  744.   428                                 -     .globl    _fmtacsi
  745.   429                                 -     .extern    _cmdblk
  746.   430                                 - _fmtacsi:
  747.   431                                 -     st    flock            ; lock FIFO
  748.   432                                 -     bsr    _delay            ; delay if necessary
  749.   433                                 -     movea.l    #WDC,a1            ; a1 = pointer to DMA chip
  750.   434                                 -     andi.w    #7,d0            ; mask off the flags to get unit num
  751.   435                                 -     moveq    #0,d1            ; clear d1
  752.   436                                 -     move.b    #$88,d1            ; next byte is the opcode
  753.   437                                 -     move.w    d1,XWDL(a1)    ;WDL
  754.   438                                 - 
  755.   439                                 -     move.b    #$8a,d1            ; following bytes are operands
  756.   440                                 -     lea    _cmdblk,a2        ; a2 = address of command block
  757.   441                                 -                     ; integrate unit # into cmd blk
  758.   442                                 -     lsl.w    #5,d0            ; shift unit number into place
  759.   443                                 -     or.b    d0,(a2)            ; first command byte = unit # | opcode
  760.   444                                 -                     ; control byte is sent seperately
  761.   445                                 -     subq.w    #2,d2            ; and dbra likes one less 
  762.   446                                 - .0:    swap    d1            ; d1.hw = operand
  763.   447                                 -     move.b    (a2)+,d1        ; d1.lw = tells controller next byte
  764.   448                                 -     swap    d1            ;      is an operand
  765.   449                                 -     move.l    d1,(a1)        ;WDCWDL
  766.   450                                 -     bsr    _qdone
  767.   451                                 -     beq.s    .1            ; if successful, go on
  768.   452                                 -     rts                ; else it timed-out, returns
  769.   453                                 - .1:    dbra    d2,.0            ; send rest of command block
  770.   454                                 - 
  771.   455                                 -     move.w    d1,XWDL(a1)    ;WDL    ; else get ready to send control byte
  772.   456                                 -     move.b    #0,d1            ; signal sending control byte
  773.   457                                 -     swap    d1            ; d1.hw = operand
  774.   458                                 -     move.b    (a2),d1            ; d1.lw = tells controller it's end
  775.   459                                 -     swap    d1            ;      of command
  776.   460                                 -     move.l    d1,(a1)            ; send it
  777.   461                                 - 
  778.   462                                 -     move.b    #$8a,d1            ; d1 = wdl value
  779.   463                                 - .2:    btst    #5,GPIP        ; wait forever for command completion
  780.   464                                 -     bne.s    .2
  781.   465                                 -     bsr    cmdcmp            ; command completed
  782.   466                                 -     bra    _hdone            ; cleanup after IRQ
  783.   467                                 - 
  784.   468                                 - 
  785.   469                                 - ;+
  786.   470                                 - ; stacsi() - start/stop an ACSI unit
  787.   471                                 - ;
  788.   472                                 - ;    d0.w = physical unit number
  789.   473                                 - ;    d2.w = command length (NCMD or LCMD)
  790.   474                                 - ;-
  791.   475                                 -     .globl    _stacsi
  792.   476                                 -     .extern    _cmdblk
  793.  
  794.  
  795.                                         acsi.s               Page 14      12:13:14 am 18-Feb-1993     Madmac 1.07  (Atari ST)
  796.  
  797.  
  798.   477                                 - _stacsi:
  799.   478                                 -     st    flock            ; lock FIFO
  800.   479                                 -     bsr    _delay            ; delay if necessary
  801.   480                                 -     movea.l    #WDC,a1            ; a1 = pointer to DMA chip
  802.   481                                 -     andi.w    #7,d0            ; mask off the flags to get unit num
  803.   482                                 -     moveq    #0,d1            ; clear d1
  804.   483                                 -     move.b    #$88,d1            ; next byte is the opcode
  805.   484                                 -     move.w    d1,XWDL(a1)    ;WDL
  806.   485                                 - 
  807.   486                                 -     move.b    #$8a,d1            ; following bytes are operands
  808.   487                                 -     lea    _cmdblk,a2        ; a2 = address of command block
  809.   488                                 -                     ; integrate unit # into cmd blk
  810.   489                                 -     lsl.w    #5,d0            ; shift unit number into place
  811.   490                                 -     or.b    d0,(a2)            ; first command byte = unit # | opcode
  812.   491                                 -                     ; control byte is sent seperately
  813.   492                                 -     subq.w    #2,d2            ; and dbra likes one less 
  814.   493                                 - .0:    swap    d1            ; d1.hw = operand
  815.   494                                 -     move.b    (a2)+,d1        ; d1.lw = tells controller next byte
  816.   495                                 -     swap    d1            ;      is an operand
  817.   496                                 -     move.l    d1,(a1)        ;WDCWDL
  818.   497                                 -     bsr    _slwqdone        ; needs a longer short timeout
  819.   498                                 -     beq.s    .1            ; if successful, go on
  820.   499                                 -     rts                ; else it timed-out, returns
  821.   500                                 - .1:    dbra    d2,.0            ; send rest of command block
  822.   501                                 - 
  823.   502                                 -     move.w    d1,XWDL(a1)    ;WDL    ; else get ready to send control byte
  824.   503                                 -     move.b    #0,d1            ; signal sending control byte
  825.   504                                 -     swap    d1            ; d1.hw = operand
  826.   505                                 -     move.b    (a2),d1            ; d1.lw = tells controller it's end
  827.   506                                 -     swap    d1            ;      of command
  828.   507                                 -     move.l    d1,(a1)            ; send it
  829.   508                                 - 
  830.   509                                 -     move.b    #$8a,d1            ; d1 = wdl value
  831.   510                                 -     bsr    _slwendcmd        ; wait for command completion
  832.   511                                 -     bra    _hdone            ; cleanup after IRQ
  833.   512                                 - 
  834.   513                                 - .endif    ;!DRIVER
  835.   514                                   
  836.   515                                   
  837.   516                                   ;+
  838.   517                                   ; Rstdelay()
  839.   518                                   ;    After talking to the DMA chip in a way that may reset it, 
  840.   519                                   ; we need a 8 8Mhz clocks (ie. 1 microsec) delay, before we can
  841.   520                                   ; talk to the chip again.
  842.   521                                   ;-
  843.   522                                       .globl    rstdelay
  844.   523                                   rstdelay:
  845.   524  0000021C  4A38FA01                   tst.b    GPIP            ; delay for 1 microsec
  846.   525  00000220  4A38FA01                   tst.b    GPIP            ; this amounts to 16 16Mhz clocks
  847.   526  00000224  4A38FA01                   tst.b    GPIP
  848.   527  00000228  4A38FA01                   tst.b    GPIP
  849.   528  0000022C  4E75                       rts
  850.   529                                   
  851.  
  852.  
  853.                                                              Page 15      12:13:14 am 18-Feb-1993     Madmac 1.07  (Atari ST)
  854. Symbol Table
  855.  
  856.                 .0 000000F8  t        MAXIDESECTS 00000100 ea             WDCWDL FFFF8604 ea 
  857.                 .0 000001AA  t             MAXLOG 0000000E ea                WDL FFFF8606 ea 
  858.                 .0 000001FE  t           MAXNPART 00000003 ea               WDSR FFFF860F ea 
  859.                 .1 0000010A  t         MAXSCSECTS 0000FFFE ea               XWDL 00000002 ea 
  860.                 .1 000001AC  t            MAXSCSI 00000008 ea               _MCH 5F4D4348 ea 
  861.                 .1 00000214  t         MAXSPSECTS 00003FFF ea           _bootdev 00000446 ea 
  862.                 .2 00000110  t                MFP FFFFFA01 ea              _bufl 000004B2 ea 
  863.                 .3 0000011A  t               MFP2 FFFFFA81 ea          _cachexst external  ax
  864.                 .4 0000011E  t               MSTE 00010010 ea            _cmdblk external  ax
  865.                 .5 00000124  t           NRETRIES 00000003 ea             _delay 00000094  t 
  866.                 .6 00000142  t             RAMBOT 01000000 ea           _drvbits 000004C2 ea 
  867.                 .7 0000014A  t           RAMMAGIC 1357BD13 ea           _dskbufp 000004C6 ea 
  868.           ACLTMOUT 00000258 ea             RAMRSV 00000080 ea            _endcmd 00000042  t 
  869.            ACSIUNT 00000007 ea              RDWDL 00000000 ea             _fdone 00000006  t 
  870.           ACSTMOUT 00000014 ea            REGBASE 00000001 ea             _hdone 0000007E  tg
  871.                AER FFFFFA03 ea           REGLSTEP 00000004 ea            _hz_200 000004BA ea 
  872.               AER2 FFFFFA83 ea            REGSTEP 00000002 ea          _p_cookie 000005A0 ea 
  873.             BCBLEN 00000014 ea                RSR FFFFFA2B ea             _qdone 0000000E  t 
  874.               BERR 00000008 ea               RSR2 FFFFFAAB ea           _rcvacsi 000000BE  tg
  875.             BPBLEN 00000012 ea                SCR FFFFFA27 ea           _slwacsi 00000005  tg
  876.            CHKDATE 19870422 ea               SCR2 FFFFFAA7 ea          _smplacsi 000000A6  tg
  877.                DDR FFFFFA05 ea             SCSIID 00000006 ea           _sysbase 000004F2 ea 
  878.               DDR2 FFFFFA85 ea            SCSIUNT 0000000F ea           _wrtacsi 00000154  tg
  879.              DEBUG 00000000 ea             SERLEN 00000003 ea            chunkno 00000004 ea 
  880.              DMAHI FFFF8609 ea                SIG 000055AA ea           chunksiz 00000042 ea 
  881.             DMALOW FFFF860D ea           SLWACLTO 00001388 ea             cmdcmp 00000046  t 
  882.             DMAMID FFFF860B ea           SLWACSTO 0000002A ea            control 00000004  t 
  883.              DOSPM 000001BE ea            SPARROW 00030000 ea               end0 00000044  t 
  884.             DOSSIG 000001FE ea                 ST 00000000 ea               end1 00000062  t 
  885.             DRIVER 00000001 ea                STA 00000003 ea              endce 0000006E  t 
  886.                ERB FFFFFA09 ea             STBOOK 00010008 ea         etv_critic 00000404 ea 
  887.             FATLEN 00000006 ea                STE 00010000 ea              flock 0000043E ea 
  888.               GPIP FFFFFA01 ea               TACR FFFFFA19 ea           hdv_boot 0000047A ea 
  889.              GPIP2 FFFFFA81 ea              TACR2 FFFFFA99 ea            hdv_bpb 00000472 ea 
  890.              HDSIZ 000001C2 ea               TADR FFFFFA1F ea           hdv_init 0000046A ea 
  891.           IDEDPLEN 00000004 ea              TADR2 FFFFFA9F ea        hdv_mediach 0000047E ea 
  892.             IDEUNT 00000010 ea               TBCR FFFFFA1B ea             hdv_rw 00000476 ea 
  893.               IERA FFFFFA07 ea              TBCR2 FFFFFA9B ea          lastacstm 00000000  t 
  894.              IERA2 FFFFFA87 ea               TBDR FFFFFA21 ea            phystop 0000042E ea 
  895.              IERB2 FFFFFA89 ea              TBDR2 FFFFFAA1 ea            pun_ptr 00000516 ea 
  896.               IINS 00000010 ea              TCDCR FFFFFA1D ea                qd0 00000010  t 
  897.               IMRA FFFFFA13 ea             TCDCR2 FFFFFA9D ea                qd1 00000028  t 
  898.              IMRA2 FFFFFA93 ea               TCDR FFFFFA23 ea                qd2 0000002C  t 
  899.               IMRB FFFFFA15 ea              TCDR2 FFFFFAA3 ea                qdq 0000003E  t 
  900.              IMRB2 FFFFFA95 ea               TDDR FFFFFA25 ea              raend 0000014E  t 
  901.               IPRA FFFFFA0B ea              TDDR2 FFFFFAA5 ea           rstdelay 0000021C  tg
  902.              IPRA2 FFFFFA8B ea                TSR FFFFFA2D ea             sacend 0000021A  t 
  903.               IPRB FFFFFA0D ea               TSR2 FFFFFAAD ea             sbaend 000001D6  t 
  904.              IPRB2 FFFFFA8D ea                 TT 00020000 ea           sblkacsi 00000190  t 
  905.               ISRA FFFFFA0F ea                UCR FFFFFA29 ea             sdelay 0000001C  t 
  906.              ISRA2 FFFFFA8F ea               UCR2 FFFFFAA9 ea            setacnt 000001F0  tg
  907.               ISRB FFFFFA11 ea                UDR FFFFFA2F ea            setadma 000001D8  tg
  908.              ISRB2 FFFFFA91 ea               UDR2 FFFFFAAF ea              waend 0000018C  t 
  909.         MAXACSECTS 000000FE ea                 VR FFFFFA17 ea               wait 0000009C  t 
  910.            MAXACSI 00000008 ea                VR2 FFFFFA97 ea 
  911.             MAXIDE 00000001 ea                WDC FFFF8604 ea 
  912.  
  913.